//
//  YHTimeIolDetailModel.m
//  ZhuKuang
//
//  Created by jjkj on 17/7/13.
//  Copyright © 2017年 jjkj. All rights reserved.
//

#import "IolDetailModel.h"
#import "AlarmDetailModel.h"
#define timeFormatter @"yyyy-MM-dd HH:mm"
@implementation IolDetailModel
/**
 处理量的小数点
 
 @param iolNum 要处理的数据
 
 @return 处理后的结果
 */
+(NSString *)getIolNum:(NSString *)iolNum
{
    if ([iolNum floatValue] != 0) {
        iolNum = [NSString stringWithFormat:@"%.2fL",[iolNum floatValue]];
    }else{
        iolNum =  @"0L";
    }
    return iolNum;
}
/**
 获取入油详情数据

 @param timeIolModel timeIolModel

 @return model数组
 */
+(NSArray *)getEnterIolDetail:(YHTimeIolModel *)timeIolModel
{
    NSDate * date = [CommClass dateFormatTimeStamp:timeIolModel.time timeFormat:TIME_FORMATTER_24];
    NSString * iol = [self getIolNum:timeIolModel.iol];
    NSArray *list = @[@{@"key":@"油站入油时间",@"value":[CommClass formatTimeStamp:date timeFormat:timeFormatter]},
                      @{@"key":@"油站入油量",@"value":iol},
                      @{@"key":@"发油单位",@"value":timeIolModel.errorUnit},
                      @{@"key":@"油品类型",@"value":timeIolModel.ioltype},
                      @{@"key":@"收油单位",@"value":timeIolModel.unit},
                      @{@"key":@"负责人",@"value":timeIolModel.people},
                      @{@"key":@"坐标地点",@"value":timeIolModel.point}];
    return [AlarmDetailModel mj_objectArrayWithKeyValuesArray:list];
}
/**
 获取出油详情数据
 
 @param timeIolModel timeIolModel
 
 @return model数组
 */
+(NSArray *)getOutIolDetail:(YHTimeIolModel *)timeIolModel
{
    NSDate * date = [CommClass dateFormatTimeStamp:timeIolModel.time timeFormat:TIME_FORMATTER_24];
    NSString * iol = [self getIolNum:timeIolModel.iol];
    NSArray *list = @[@{@"key":@"油站出油时间",@"value":[CommClass formatTimeStamp:date timeFormat:timeFormatter]},
                      @{@"key":@"油站出油量",@"value":iol},
                      @{@"key":@"收油车辆",@"value":timeIolModel.car},
                      @{@"key":@"油品类型",@"value":timeIolModel.ioltype},
                      @{@"key":@"司机",@"value":timeIolModel.driver},
                      @{@"key":@"所属部门",@"value":timeIolModel.unit},
                      @{@"key":@"坐标地点",@"value":timeIolModel.point},
                      @{@"key":@"负责人",@"value":timeIolModel.people}];
    return [AlarmDetailModel mj_objectArrayWithKeyValuesArray:list];
}
/**
 获取车辆加油、加油机详情数据
 
 @param timeIolModel timeIolModel
 
 @return model数组
 */
+(NSArray *)getRefuelIolDetail:(YHTimeIolModel *)timeIolModel
{
    NSDate * date = [CommClass dateFormatTimeStamp:timeIolModel.time timeFormat:TIME_FORMATTER_24];
    NSString * iol = [self getIolNum:timeIolModel.iol];
    NSArray *list = @[@{@"key":[timeIolModel.type stringByAppendingString:@"时间"],@"value":[CommClass formatTimeStamp:date timeFormat:timeFormatter]},
                      @{@"key":[timeIolModel.type stringByAppendingString:@"量"],@"value":iol},
                      @{@"key":@"加油车辆",@"value":timeIolModel.car},
                      @{@"key":@"出油油槽车",@"value":timeIolModel.errorUnit},
                      @{@"key":@"卡车司机",@"value":timeIolModel.driver},
                      @{@"key":@"加油员",@"value":timeIolModel.people},
                      @{@"key":@"所属部门",@"value":timeIolModel.unit},
                      @{@"key":@"坐标地点",@"value":timeIolModel.point}];
    return [AlarmDetailModel mj_objectArrayWithKeyValuesArray:list];

}
/**
 获取油罐出油、入油的报警详情数据
 
 @param timeSingleModel timeSingleModel
 
 @param type 入油／出油
 
 @return model数组
 */
+(NSArray *)getSingleIolDetail:(YHTimeSingleModel *)timeSingleModel withType:(NSString *)type
{
    NSString * title = @"入油";
    if ([type containsString:@"出油"]) {
        title = @"出油";
    }
    NSArray *list = @[@{@"key":[title stringByAppendingString:@"前量"],@"value":[self getIolNum:timeSingleModel.iolbefor]},
                      @{@"key":[title stringByAppendingString:@"量"],@"value":[self getIolNum:timeSingleModel.iol]},
                      @{@"key":[title stringByAppendingString:@"后量"],@"value":[self getIolNum:timeSingleModel.iolafter]},
                      @{@"key":[title stringByAppendingString:@"异常量"],@"value":[self getIolNum:timeSingleModel.iolerror]}];
    return [AlarmDetailModel mj_objectArrayWithKeyValuesArray:list];

}

/**
 获取车辆报警中油耗、超速、故障报警详情数据
 
 @param carIolModel timeIolModel
 
 @param type 0油耗 2故障 3超速
 
 @return model数组
 */
+(NSArray *)getCarAlarmDetail:(YHIolInfoListModel *)carIolModel withType:(NSInteger)type
{
    NSDate * date = [CommClass dateFormatTimeStamp:carIolModel.errortime timeFormat:TIME_FORMATTER_24];
    NSString * typeKey = @"油耗异常量";
    NSString * typeValue = [self getIolNum:carIolModel.iolerror];
    if (type == 2) {
        typeKey = @"故障报警类型";
        typeValue = carIolModel.iolerror;
    }
    if (type == 3) {
        typeKey = @"超速速度";
        typeValue = [carIolModel.iolerror stringByAppendingString:@"km/h"];
    }
    NSArray *list = @[@{@"key":@"报警时间",@"value":[CommClass formatTimeStamp:date timeFormat:timeFormatter]},
                      @{@"key":@"报警车辆",@"value":carIolModel.car},
                      @{@"key":@"车辆类型",@"value":carIolModel.carType},
                      @{@"key":@"所属部门",@"value":carIolModel.errorUnit},
                      @{@"key":@"司机",@"value":carIolModel.driver},
                      @{@"key":typeKey,@"value":typeValue},
                      @{@"key":@"坐标地点",@"value":carIolModel.point}];
    return [AlarmDetailModel mj_objectArrayWithKeyValuesArray:list];
}


/**
 获取车辆加油报警详情数据
 
 @param timeIolModel timeIolModel
 
 @return model数组
 */
+(NSArray *)getCarRefuelIolAlarmDetail:(YHTimeIolModel *)timeIolModel
{
    NSDate * date = [CommClass dateFormatTimeStamp:timeIolModel.errortime timeFormat:TIME_FORMATTER_24];
    NSArray *list = @[@{@"key":@"报警时间",@"value":[CommClass formatTimeStamp:date timeFormat:timeFormatter]},
                      @{@"key":@"加油前量",@"value":[self getIolNum:timeIolModel.iolbefor]},
                      @{@"key":@"加油量",@"value":[self getIolNum:timeIolModel.iol]},
                      @{@"key":@"加油后量",@"value":[self getIolNum:timeIolModel.iolafter]},
                      @{@"key":@"加油异常量",@"value":[self getIolNum:timeIolModel.iolerror]},
                      @{@"key":@"加油车辆",@"value":timeIolModel.car},
                      @{@"key":@"加油员",@"value":timeIolModel.people},
                      @{@"key":@"司机姓名",@"value":timeIolModel.driver},
                      @{@"key":@"坐标地点",@"value":timeIolModel.point}];
    return [AlarmDetailModel mj_objectArrayWithKeyValuesArray:list];
    
}
@end
